<?php
class It_Form_Equipment extends Zend_Form
{

    public function init()
    {
        // id
        $this->setName("equipment");

        $equipmentId = new Zend_Form_Element_Hidden('$equipmentId');
 		$equipmentId->removeDecorator('HtmlTag');
 		$equipmentId->removeDecorator('Label');

        $equipmentName = new Zend_Form_Element_Text('equipmentName');
        $equipmentName->setLabel('Tên thiết bị *')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $equipmentName->setAttrib('size', 60);

        $code = new Zend_Form_Element_Text('code');
        $code->setLabel('Mã quản lý *')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $code->setAttrib('size', 60);
        $code->setAttrib('readonly', 'readonly');

        $ip = new Zend_Form_Element_Text('ip');
        $ip->setLabel('IP MAC')->addFilter('StripTags')->addFilter('StringTrim');
        $ip->setAttrib('size', 60);
        
        $iplan1 = new Zend_Form_Element_Text('iplan1');
        $iplan1->setLabel('IP Lan 1')->addFilter('StripTags')->addFilter('StringTrim');
        $iplan1->setAttrib('size', 60);
        
        $iplan2 = new Zend_Form_Element_Text('iplan2');
        $iplan2->setLabel('IP Lan 2')->addFilter('StripTags')->addFilter('StringTrim');
        $iplan2->setAttrib('size', 60);
        
        $position = new Zend_Form_Element_Text('position');
        $position->setLabel('Vị trí *')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $position->setAttrib('size', 60);

        $function = new Zend_Form_Element_Text('function');
        $function->setLabel('Chức năng')->addFilter('StripTags')->addFilter('StringTrim');
        $function->setAttrib('size', 60);

        $endUser = new Zend_Form_Element_Text('endUser');
        $endUser->setLabel('Người sử dụng')->addFilter('StripTags')->addFilter('StringTrim');
        $endUser->setAttrib('size', 60);

        $note = new Zend_Form_Element_Textarea('note');
        $note->setLabel('Ghi chú')->addFilter('StripTags')->addFilter('StringTrim');
        $note->setAttrib('cols', 45)->setAttrib('rows', 6);

        $category = new Zend_Form_Element_Select('categoryId');
        $category->setLabel('Nhóm thiết bị *')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $category->setAttrib('style', 'width: 200px');
      	$model_category = new It_Model_Category();
        $categories = $model_category->fetchAll();
        foreach($categories as $c)
        	$category->addMultiOption($c->categoryId,$c->categoryName);
        
        $project = new Zend_Form_Element_Multiselect('projectId');
        $project->setLabel('Dự án (Được chọn nhiều) *')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $model_project = new It_Model_Project();
        $projectData = $model_project->fetchAll();
        foreach ($projectData as $p)
        	$project->addMultiOption($p->projectId ,$p->projectName);

        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setAttrib('id','submitbutton');
        $submit->setAttrib('class',"button medium");

        $this->addElements(array (
            $equipmentId, $equipmentName ,$category ,$code, $ip, $iplan1, $iplan2, $position, $function, $endUser, $note , $project, $submit
        ));
    }
}

